//
// Created by 田建昆 on 2020/12/21.
//

#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>

#ifndef CODEBASE_UTILS_H
#define CODEBASE_UTILS_H

#define try \
    jmp_buf jmpbuff;\
    int e = setjmp(jmpbuff); \
    if (e == 0) jmp_stack_push(&jmpbuff); \
    if (e == 0)

#define throw(e) \
    longjmp(*jmp_stack_pop(), e);

#define catch(e) \
    if (!(e)) jmp_stack_pop(); \
    else

void jmp_stack_push(jmp_buf* jmpbufferr);
jmp_buf *jmp_stack_pop();

#endif //CODEBASE_UTILS_H
